

<title>%1</title>

<% content_for :auto_discovery do %>
  <% if @current_user %>
    <%= auto_discovery_link_tag(:atom, feeds_user_format_path(@current_user.feed_code, :atom), {:title => t('titles.rss.course_announcements', "Course Announcements Atom Feed")}) %>
  <% end %>
<% end %>

<% css_bundle :context_list, :course_list %>
<% js_bundle :course_list %>
<% @favorite_course_ids = @current_user.courses_with_primary_enrollment(:favorite_courses).map(&:id) %>
<% @show_star_column = true %>
  <div class="header-bar">
    <h2>{{#t}}All Courses{{/t}}</h2>
  </div>

  <div class="ic-Action-header content--hasMarginTop">
    <div class="ic-Action-header__Secondary">
      <% if @domain_root_account.feature_enabled?(:course_catalog) %>
        <%= link_to t('browse_more_courses', 'Browse More Courses'), "/search/all_courses/", class:"Button" %>
      <% end %>

      <% if show_user_create_course_button(@current_user) %>
          <button type="button"
                  id="start_new_course"
                  class="Button element_toggler"
                  aria-controls="new_course_form"
                  aria-label="{{#t}}Add a Course{{/t}}">
                  {{> icons/plus}} {{#t}}Course{{/t}}</button>
          {{> views/shared/new_course_form}}
      <% end %>
    </div>
  </div>

<% if @current_enrollments.empty? %>
  {{#t}}You are not enrolled in any courses.{{/t}}
<% else %>
  <table id="my_courses_table" class="ic-Table ic-Table--bordered course-list-table">
    <thead>
      <tr>
        <th scope="col" class="course-list-star-column"><span class="screenreader-only">{{#t}}Favorites{{/t}}</span></th>
        <th scope="col" class="course-list-course-title-column course-list-no-left-border">{{#t}}Course{{/t}}</th>
        <th scope="col" class="course-list-nickname-column course-list-no-left-border">{{#t}}Nickname{{/t}}</th>
        <th scope="col" class="course-list-term-column course-list-no-left-border">{{#t}}Term{{/t}}</th>
        <th scope="col" class="course-list-enrolled-as-column course-list-no-left-border">{{#t}}Enrolled as{{/t}}</th>
        <th scope="col" class="course-list-published-column course-list-no-left-border">{{#t}}Published{{/t}}</th>
      </tr>
    </thead>
    <tbody>
      <% @current_enrollments.each do |enrollment| %>
        {{> views/shared/current_enrollment}}
      <% end %>
    </tbody>
  </table>
<% end %>

<% @show_star_column = true %>
<% unless @past_enrollments.empty? %>
  <div class="content--hasMarginTop">
    <h2>{{#t}}Past Enrollments{{/t}}</h2>
  </div>
  <table id="past_enrollments_table" class="ic-Table ic-Table--bordered course-list-table">
    <thead>
      <tr>
        <th scope="col" class="course-list-star-column"><span class="screenreader-only">{{#t}}Favorites{{/t}}</span></th>
        <th scope="col" class="course-list-course-title-column course-list-no-left-border">{{#t}}Course{{/t}}</th>
        <th scope="col" class="course-list-nickname-column course-list-no-left-border">{{#t}}Nickname{{/t}}</th>
        <th scope="col" class="course-list-term-column course-list-no-left-border">{{#t}}Term{{/t}}</th>
        <th scope="col" class="course-list-enrolled-as-column course-list-no-left-border">{{#t}}Enrolled as{{/t}}</th>
        <th scope="col" class="course-list-published-column course-list-no-left-border">{{#t}}Published{{/t}}</th>
      </tr>
    </thead>
    <tbody>
      <% @past_enrollments.each do |enrollment| %>
        {{> views/shared/current_enrollment}}
      <% end %>
    </tbody>
  </table>
<% end %>

<% unless @future_enrollments.empty? %>
  <div class="content--hasMarginTop">
    <h2>{{#t}}Future Enrollments{{/t}}</h2>
  </div>
  <table id="future_enrollments_table" class="ic-Table ic-Table--bordered course-list-table">
    <thead>
      <tr>
        <th scope="col" class="course-list-star-column"><span class="screenreader-only">{{#t}}Favorites{{/t}}</span></th>
        <th scope="col" class="course-list-course-title-column course-list-no-left-border">{{#t}}Course{{/t}}</th>
        <th scope="col" class="course-list-nickname-column course-list-no-left-border">{{#t}}Nickname{{/t}}</th>
        <th scope="col" class="course-list-term-column course-list-no-left-border">{{#t}}Term{{/t}}</th>
        <th scope="col" class="course-list-enrolled-as-column course-list-no-left-border">{{#t}}Enrolled as{{/t}}</th>
        <th scope="col" class="course-list-published-column course-list-no-left-border">{{#t}}Published{{/t}}</th>
      </tr>
    </thead>
    <tbody>
      <% @future_enrollments.each do |enrollment| %>
        {{> views/shared/current_enrollment}}
      <% end %>
    </tbody>
  </table>
<% end %>

<% @show_star_column = false %>
<% unless @visible_groups.empty? %>
  <div class="content--hasMarginTop">
    <h2>{{#t}}My Groups{{/t}}</h2>
  </div>
  <table id="my_groups_table" class="ic-Table ic-Table--bordered course-list-table">
    <thead>
      <tr>
        <th scope="col" class="course-list-group-column">{{#t}}Group{{/t}}</th>
        <th scope="col" class="course-list-course-title-column course-list-no-left-border">{{#t}}Course{{/t}}</th>
        <th scope="col" class="course-list-term-column course-list-no-left-border">{{#t}}Term{{/t}}</th>
      </tr>
    </thead>
    <tbody>
      <% @visible_groups.each do |group| %>
        <% group_name = group.name %>
        <tr>
          <td>
            <a href=<%= group_path(group) %>>
              <span class="name" title="<%= group_name %>">
                <%= group_name %>
              </span>
            </a>
          </td>
          <td class="course-list-no-left-border">
            <span class="name"><%= group.context.name %></span>
          </td>
          <td class="course-list-no-left-border">
            <% if group.context_type == 'Course' && !group.context.enrollment_term.default_term? %>
              <%= group.context.enrollment_term.name %>
            <% end %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
